Skip to content

Conversation

@Nyholm
Copy link
Contributor

@Nyholm Nyholm commented Nov 28, 2025

Description

When running this without twig I get build errors because we are missing Twigs AbstractExtension

Issues

Reminders

@Litarnus
Copy link
Contributor

Hi @Nyholm! Thanks for opening the PR, it looks good to me!

The pipelines are a bit broken right now because of security advisories. We will most likely fix this by Monday and then we can get this PR merged

@Litarnus Litarnus self-requested a review December 1, 2025 10:02
}

if (!$isConfigEnabled) {
$container->removeDefinition(TwigSentryExtension::class);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: TwigSentryExtension incorrectly removed when tracing disabled

TwigSentryExtension is being removed when Twig tracing is disabled, preventing users from using Twig functions like sentry_trace_meta() even when Twig is installed. TwigSentryExtension provides general Sentry Twig functions and should only be removed when Twig itself isn't installed (already handled at line 75), not when tracing is disabled. Only TwigTracingExtension should be removed when tracing is disabled.

Fix in Cursor Fix in Web

// Remove Twig extension service if Twig is not installed to avoid autoloading failures on Symfony 8
if (!class_exists(\Twig\Extension\AbstractExtension::class)) {
$container->removeDefinition(\Sentry\SentryBundle\Twig\SentryExtension::class);
$container->removeDefinition(TwigSentryExtension::class);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: TwigTracingExtension not removed when Twig unavailable

When AbstractExtension doesn't exist (Twig not installed), only TwigSentryExtension is removed. However, TwigTracingExtension also extends AbstractExtension and will cause autoloading failures if Twig is unavailable. Both extensions should be removed when checking for Twig availability to prevent compilation errors on Symfony 8.

Fix in Cursor Fix in Web

@Litarnus
Copy link
Contributor

Litarnus commented Dec 1, 2025

@Nyholm This might have become obsolete because of a guard introduced in the Symfony 8 PR that I merged today:

       // Remove Twig extension service if Twig is not installed to avoid autoloading failures on Symfony 8
        if (!class_exists(\Twig\Extension\AbstractExtension::class)) {
            $container->removeDefinition(\Sentry\SentryBundle\Twig\SentryExtension::class);
        }

Do you mind checking against 5.7.0 and see if the error persists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants